package de.tu_darmstadt.gdi1.xcom.controller.ai;

import de.tu_darmstadt.gdi1.framework.utils.Point;

/**
 * Node used in pathfinding.
 * This corresponds to a non solid
 * point in the map and links
 * to a already checked node that
 * is a waypoint to get here
 * 
 * @author michael
 *
 */
public class GameGridNode {
	public Point pointHere;
	public Point pointOrigin;
	public int pathCost;
	public cellStatus status;
	
	enum cellStatus {
		FAR, BORDER, CHECKED,BLOCKED;
	}
	
	public GameGridNode(Point here, Point origin) {
		pointHere = here;
		pointOrigin = origin;
		pathCost = Integer.MAX_VALUE;
	}
	
	public GameGridNode(Point here, Point origin, int cost, cellStatus status) {
		pointHere = here;
		pointOrigin = origin;
		pathCost = cost;
		this.status = status;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((pointHere == null) ? 0 : pointHere.hashCode());
		result = prime * result
				+ ((pointOrigin == null) ? 0 : pointOrigin.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		GameGridNode other = (GameGridNode) obj;
		if (pointHere == null) {
			if (other.pointHere != null)
				return false;
		} else if (!pointHere.equals(other.pointHere))
			return false;
		if (pointOrigin == null) {
			if (other.pointOrigin != null)
				return false;
		} else if (!pointOrigin.equals(other.pointOrigin))
			return false;
		return true;
	}
	
	
	
	
}
